import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLOutput;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoLocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAdjusters;

/*
 *Description:
 *User:laoHu
 *Created with Intellij IDEA 2025
 *Data:2025.07.13
 *Time:23:28
 */
public class Main{
    //BigDecimal大进制
    public static void main(String[] args) {
        //加减乘除
        BigDecimal bigDecimal = new BigDecimal(12);
        BigDecimal bigDecimal1 = new BigDecimal(13);
        System.out.println(bigDecimal1.add(bigDecimal1));
        System.out.println(bigDecimal1.multiply(bigDecimal));
        System.out.println(bigDecimal1.divide(bigDecimal,2, RoundingMode.HALF_UP));
        System.out.println(bigDecimal1.subtract(bigDecimal));
    }
    public static void main7(String[] args) {
        //传double精度不准确，而String类型的比较准确
        BigDecimal bigDecimal = new BigDecimal(3.14);
        System.out.println(bigDecimal);
        BigDecimal bigDecimal1 = new BigDecimal("3.14");
        System.out.println(bigDecimal1);
    }

    //常用工具类：LocalDataTime
    public static void main6(String[] args) {
        //获取当前周的周一和周日
        LocalDateTime currentDateTime = LocalDateTime.now();
         //获取本周周一日期
        LocalDateTime firstDateTime = currentDateTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
        //获取本周周日日期
        LocalDateTime lastDayOfWeek = currentDateTime.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
        System.out.println("本周周一日期：" + firstDateTime);
        System.out.println("本周周日日期：" + lastDayOfWeek);
        //获取本月第一天日期
        LocalDateTime firstDayOfMonth = currentDateTime.with(TemporalAdjusters.firstDayOfMonth());
        System.out.println("本月第一天日期： " + firstDayOfMonth);
        //获取本月最后一天日期
        LocalDateTime lastDayOfMonth = currentDateTime.with(TemporalAdjusters.lastDayOfMonth());
        System.out.println("本月最后一天日期： " + lastDayOfMonth);

    }

    public static void main5(String[] args) {
        //增加或减少日期
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println("增加一天后的日期： " + localDateTime.plusDays(1));
        System.out.println("减少一天后的日期： " + localDateTime.minusDays(1));
    }
    public static void main4(String[] args) {
        //获取具体的天数：周 月 年
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println("本周的星期" + localDateTime.getDayOfWeek());
        System.out.println("本月的" + localDateTime.getDayOfMonth() + "号");
        System.out.println("本年的第" + localDateTime.getDayOfYear() + "天");
    }
    public static void main3(String[] args) {
        //根据字符串获取指定格式的日期
        String stringDate = "2025-07-13 23:46:00";
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime localTime = LocalDateTime.parse(stringDate,dateTimeFormatter);
        System.out.println(localTime);
    }
    public static void main2(String[] args) {
        //获取年月日
        LocalDateTime localDateTime = LocalDateTime.now();
        int year = localDateTime.getYear();
        int month = localDateTime.getMonthValue();
        int day = localDateTime.getDayOfMonth();
        int hour = localDateTime.getHour();
        int minute = localDateTime.getMinute();
        int second = localDateTime.getSecond();
        System.out.println("year :" + year);
        System.out.println("month :" + month);
        System.out.println("day :" + day);
        System.out.println("hour :" + hour);
        System.out.println("minute :" + minute);
        System.out.println("second :" + second);

    }
    public static void main1(String[] args) {
        //获取当前时间
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime);
        //指定时间
        LocalDateTime localDateTime1 =  LocalDateTime.of(2025,7,12,10,30,00);
        System.out.println(localDateTime1);
        //从序列中读取
        LocalDateTime localDateTime2 = LocalDateTime.parse("2025-07-13T23:36:11");
        System.out.println(localDateTime2);
    }
}
